const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require('webpack')
module.exports = {
    entry: "./src/index.ts",
    output: {
        path: __dirname,
        filename: "./dist/un-tree.min.js",
    },
    module: {
        rules: [
            {test: /\.css$/, use: ["style-loader", "css-loader"]},
            {
                test: /\.scss$/,
                use: [
                    {loader: "style-loader"},
                    {
                        loader: "css-loader",
                        options: {
                            sourceMap: true,
                        },
                    },
                    {
                        loader: "postcss-loader",
                        options: {
                            sourceMap: true,
                            config: {
                                path: "postcss.config.js", // 这个得在项目根目录创建此文件
                            },
                        },
                    },
                    {
                        loader: "sass-loader",
                        options: {sourceMap: true},
                    },
                ],
            },
            {
                test: /\.tsx?$/,
                use: 'ts-loader',
                exclude: /node_modules/,
            }
        ],
    },
    resolve: {
        extensions: [ '.tsx', '.ts', '.js' ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            inject: "head",
            template: "./public/index.html",
        }),
        new webpack.BannerPlugin('\n @author zhuzhaofeng\n @description 树形图 \n @version 2.0.0 \n https://gitee.com/zhuzhaofeng/UNTree ')
    ],
    devServer: {
        contentBase: path.join(__dirname, "./dist"),
        port: 8080,
        open: true,
    },
};
